package com.king.hpeproject.service.perm.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.king.hpeproject.entity.perm.OrganizationDo;
import com.king.hpeproject.mapper.OrganizationMapper;
import com.king.hpeproject.service.perm.OrganizationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("organizationService")
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, OrganizationDo> implements OrganizationService {

    @Resource
    private OrganizationMapper organizationMapper;

    @Override
    public boolean isHead(Long orgId) {
        LambdaQueryWrapper<OrganizationDo> organizationWrapper = Wrappers.lambdaQuery();
        organizationWrapper.eq(OrganizationDo::getOrgId, orgId);
        organizationWrapper.select(OrganizationDo::getIsHead);
        OrganizationDo organizationDo = organizationMapper.selectOne(organizationWrapper);
        return Boolean.TRUE.equals(organizationDo.getIsHead());
    }
}
